import { createSlice } from "@reduxjs/toolkit";
import axios from "axios";

/**
 * billStore
 */
const billStore = createSlice({
	name: "bill",
	initialState: { billList: [] },
	reducers: {
		setBillList(state, action) {
			state.billList = action.payload;
		},
	},
});

const { setBillList } = billStore.actions;

export function getBillList() {
	return async () => {
		const response = await axios.get("http://localhost:10000/ka");
		setBillList(response.data);
	};
}
export const billReducer = billStore.reducer;
